package com.biter.bean;


import net.sf.json.JSONObject;

import com.biter.R;

import android.view.View;
import android.widget.TextView;

public class MarketItemBean {
	private View itemView;
    private TextView buyvalText;
    private TextView sellvalText;
    private TextView heightvalText;
    private TextView lowvalText;
    private TextView volvalText;
    private TextView lastvalText;
    private TextView marketNamevalText;
	
	public MarketItemBean(View itemView) {
		this.itemView = itemView;
		this.buyvalText = (TextView)itemView.findViewById(R.id.buyval);
		this.sellvalText = (TextView)itemView.findViewById(R.id.sellval);
		this.heightvalText = (TextView)itemView.findViewById(R.id.heightval);
		this.lowvalText = (TextView)itemView.findViewById(R.id.lowval);
		this.volvalText = (TextView)itemView.findViewById(R.id.volval);
		this.lastvalText = (TextView)itemView.findViewById(R.id.lastval);
		this.marketNamevalText = (TextView)itemView.findViewById(R.id.marketName);
		
	}

	public void setJsonData(String jsonData,String marketName){
		JSONObject jsonObject = JSONObject.fromObject(jsonData);
		JSONObject tickerObject = (JSONObject)jsonObject.get("ticker");
		buyvalText.setText(tickerObject.getString("buy"));
		sellvalText.setText(tickerObject.getString("sell"));
		heightvalText.setText(tickerObject.getString("high"));
		lowvalText.setText(tickerObject.getString("low"));
		String vol = tickerObject.getString("vol");
		vol = vol.substring(0,vol.indexOf(".")+2);
		volvalText.setText(vol);
		lastvalText.setText(tickerObject.getString("last"));
		marketNamevalText.setText(marketName);
	}
	
}
